//引入路由组件
// import Home from '@/pages/Home'
/* import Search from '@/pages/Search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Detail from '@/pages/Detail'
import ShopCart from '@/pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import Center from '@/pages/Center' */
import PaySuccess from '@/pages/PaySuccess'
import AddCartSuccess from '@/pages/AddCartSuccess'
//二级路由
import myOrder from '@/pages/Center/myOrder'
import groupOrder from '@/pages/Center/groupOrder'

//路由懒加载
// const Foo = () => import('@/pages/Home')

export default (
    [
        {
            name:'center',
            path:'/center',
            component:() => import('@/pages/Center'),
            children:[
                {
                    name:'myorder',
                    path:'myorder',
                    component:myOrder
                },
                {
                    name:'grouporder',
                    path:'grouporder',
                    component:groupOrder
                },
                {
                    path:'/center',
                    redirect:'/center/myorder'
                }
            ]
        },
        {
            name: 'paysuccess',
            path: '/paysuccess',
            component: PaySuccess,
            meta: {
                ShowFooter: true
            },
            beforeEnter: (to, from, next) => {
                // 路由独享守卫，当前路由只能由pay跳进来，其他路由一律禁止
                if(from.path == '/pay'){
                    next()
                }else{
                    alert('该路由只能由支付页面跳转！')
                    next(from.path)
                }
            }
        },
        {
            name: 'pay',
            path: '/pay',
            component: () => import('@/pages/Pay'),
            meta: {
                ShowFooter: true
            },
            beforeEnter: (to, from, next) => {
                // 路由独享守卫，当前路由只能由trade跳进来，其他路由一律禁止
                if(from.path == '/trade'){
                    next()
                }else{
                    alert('该路由只能由交易页面跳转！')
                    next(from.path)
                }
            }
        },
        {
            name: 'trade',
            path: '/trade',
            component: () => import('@/pages/Trade'),
            meta: {
                ShowFooter: true
            },
            beforeEnter: (to, from, next) => {
                // 路由独享守卫，当前路由只能由shopcart跳进来，其他路由一律禁止
                if(from.path == '/shopcart'){
                    next()
                }else{
                    alert('该路由只能由购物车页面跳转！')
                    next(from.path)
                }
            }
        },
        {
            name: 'shopcart',
            path: '/shopcart',
            component: () => import('@/pages/ShopCart'),
            meta: {
                ShowFooter: true
            }
        },
        {
            name: 'addcartsuccess',
            path: '/addcartsuccess',
            component: AddCartSuccess,
            meta: {
                ShowFooter: true
            },
            beforeEnter: (to, from, next) => {
                // 路由独享守卫，当前路由只能由detail跳进来，其他路由一律禁止
                if(from.name == 'detail'){
                    next()
                }else{
                    alert('该路由只能由商品详情页面跳转！')
                    next(from.path)
                }
            }
        },
        {
            path: '/home',
            component: () => import('@/pages/Home'),
            meta: {
                ShowFooter: true
            }
        },
        {
            name: 'search',
            //指定params参数可传可不传
            path: '/search/:keyword?',
            component: () => import('@/pages/Search'),
            meta: {
                ShowFooter: true
            },
            //props可以将数据传递给当前组件中（search）
            /* props:($route)=>{
                return {keyword:$route.params.keyword,k:$route.query.k}
            } */
        },
        {
            path: '/login',
            component: () => import('@/pages/Login'),
        },
        {
            path: '/register',
            component: () => import('@/pages/Register'),
        },
        {
            name: 'detail',
            path: '/detail/:id',
            component: () => import('@/pages/Detail'),
        },
        //重定向,项目首页
        {
            path: '*',
            redirect: '/home'
        }

    ]
)